import { getItem } from '../../../utils/storage'
type Token = {
  token: string
  refresh_token: string
}

export default function LoginReducer(
  pre = getItem() || {},
  action: {
    type: 'USER_LOGIN'
    data: { data?: Token } | { type: 'LOGIN_OUT'; data: null }
  }
) {
  if (action.type === 'USER_LOGIN') {
    return action.data.data
  } else if (action.type === 'LOGIN_OUT') {
    return {}
  }
  return pre
}
